package com.lcx.movie.controller;
import com.lcx.movie.entity.Stats;
import com.lcx.movie.mapper.StatsMapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
/**
 * @Description  统计数据控制类
 * @version 1.0 
 * @author 李丽君
 * @date 2025/3/19 10:06
 */
@RestController
@CrossOrigin(origins = "*")
public class StatsController {
    @Autowired
    private StatsMapper statsMapper;

    /**
     * 平台管理员统计数量
     * @return 统计数据实体
     */
    @GetMapping("/stats")
    public Stats getStats() {
        Stats stats = new Stats();
        stats.setBookmarks(statsMapper.getUserCount());
        stats.setLikes(statsMapper.getMovieCount());
        stats.setEvents(statsMapper.getCinemaCount());
        stats.setComments(statsMapper.getCommentCount());
        stats.setHallcounts(statsMapper.getHallCounts());
        stats.setSchedulecounts(statsMapper.getScheduleCounts());
        stats.setSeatscount(statsMapper.getSeatsCount());
        stats.setSnackscount(statsMapper.getSnackCount());
        stats.setBancount(statsMapper.getBanCount());
        System.out.println("人数："+statsMapper.getUserCount());
        System.out.println("影片数："+statsMapper.getMovieCount());
        return stats;
    }

    /**
     * // 统计影院管理员所有的影片数量
     * @param cinemaId 影院id
     * @return 受影响的行数
     */
    @GetMapping("/getCinemaManageMovie")
    public int getCinemaManageMovie(int cinemaId){
        int cinemaManageMovie = statsMapper.getCinemaManageMovie(cinemaId);
        System.out.println("cinemaManageMovie "+cinemaManageMovie);
        return cinemaManageMovie;
    }

    /**
     *   // 统计影院管理员所有的放映厅
     * @param cinemaId 影院id
     * @return 受影响的行数
     */
    @GetMapping("/getCinemaManageHall")
    public int getCinemaManageHall(int cinemaId){
        int cinemaManageHall = statsMapper.getCinemaManageHall(cinemaId);
        System.out.println("cinemaManageHall = " + cinemaManageHall);
        return cinemaManageHall;
    }

    /**
     * // 统计影院有多少场次
     * @param cinemaId 影院id
     * @return 受影响的行数
     */
    @GetMapping("/getCinemaManageSchedule")
    public int getCinemaManageSchedule(int cinemaId){
        int cinemaManageSchedule = statsMapper.getCinemaManageSchedule(cinemaId);
        System.out.println("cinemaManageSchedule = " + cinemaManageSchedule);
        return cinemaManageSchedule;
    }

    /**
     * // 根据影院id查询座位数量
     * @param cinemaId 影院id
     * @return 受影响的行数
     */
    @GetMapping("/getCinemaManageSeats")
    int getCinemaManageSeats(int cinemaId){
        int cinemaManageSeats = statsMapper.getCinemaManageSeats(cinemaId);
        System.out.println("cinemaManageSeats = " + cinemaManageSeats);
        return cinemaManageSeats;
    }

    /**
     * // 根据影院id查询电影票的营业额
     * @param cinemaId 影院id
     * @return 受影响的行数
     */
    @GetMapping("/getCinemaManageMoviePrice")
    int getCinemaManageMoviePrice(int cinemaId){
        int cinemaManageMoviePrice = statsMapper.getCinemaManageMoviePrice(cinemaId);
        System.out.println("cinemaManageMoviePrice = " + cinemaManageMoviePrice);
        return cinemaManageMoviePrice;
    }

    /**
     * // 根据影院id查询出电影的评论数量
     * @param cinemaId 影院id
     * @return 受影响的行数
     */
    @GetMapping("/getCinemaManageMovieComment")
    int getCinemaManageMovieComment(int cinemaId){
        int cinemaManageMovieComment = statsMapper.getCinemaManageMovieComment(cinemaId);
        System.out.println("cinemaManageMovieComment = " + cinemaManageMovieComment);
        return cinemaManageMovieComment;
    }
}
